Skip to content

[Security] fix pull_request_target workflow injection (pwn request)#3117

Open
dpfaffenbauer wants to merge 2 commits into
2026.xfrom
fix/pull-request-target-pwn-2026.x
Open

[Security] fix pull_request_target workflow injection (pwn request)#3117
dpfaffenbauer wants to merge 2 commits into
2026.xfrom
fix/pull-request-target-pwn-2026.x

Conversation

@dpfaffenbauer

Copy link
Copy Markdown
Member

Security: fix pull_request_target pwn-request vulnerability

The CI workflows here trigger on pull_request_target while checking out the PR head from the fork (ref: …head.sha, repository: …head.repo.full_name). That runs untrusted fork code in the trusted base-repo context — with repository secrets (PIMCORE_PRODUCT_KEY, PIMCORE_INSTANCE_IDENTIFIER, PIMCORE_SECRET) and a writable GITHUB_TOKEN. Classic "pwn request"; actions/checkout@v6 now hard-blocks it — this is what breaks the Behat job on #3113.

Fix

Switch these workflows from pull_request_target to pull_request, so fork PRs run in the fork's restricted context (no secrets, read-only token). Same code runs, but nothing sensitive to steal and nothing to push.

frontend-build.yaml additionally gets an if guard restricting it to same-repo branches — it auto-commits built Studio assets with a writable token, which a fork PR can't do under pull_request anyway.

cla-check.yml intentionally keeps pull_request_target (reads PR metadata only, no fork checkout).

Trade-off: fork PRs no longer receive the Pimcore secrets. Same-repo branches/PRs and push keep them. If pimcore-install requires the product key, external fork PRs may fail at install and need a key-less test install path.

Covers all affected workflows on 2026.x, including the version-suffixed -5.0 / -5.1 variants that live only on this branch.

One of a set of PRs across supported branches (5.0 → 5.1 → 2026.x); 4.1 was already fixed. Each branch is fixed independently because the affected file sets differ per branch (e.g. the -5.x files and frontend-build/license-check exist only on higher branches).

🤖 Generated with Claude Code

Switch fork-checkout CI workflows from pull_request_target to pull_request
so untrusted fork code no longer runs with secrets and a writable token.
Restrict frontend-build (auto-commit, write token) to same-repo branches.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 24, 2026 16:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens CoreShop’s GitHub Actions CI against “pwn request” attacks by removing pull_request_target usage from workflows that execute PR code, ensuring fork PRs run with restricted permissions (no secrets, read-only token).

Changes:

  • Switch multiple CI workflows from pull_request_target to pull_request across 2026.x, 5.1, and 5.0 variants.
  • Add a same-repo guard to frontend-build.yaml to avoid running the auto-commit build job on fork PRs.
  • Keep cla-check.yml on pull_request_target (metadata-only), consistent with the PR description.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.github/workflows/static.yml Switch trigger to pull_request to avoid trusted-context execution of fork code.
.github/workflows/static-5.1.yml Same trigger hardening for the 5.1 branch variant.
.github/workflows/static-5.0.yml Same trigger hardening for the 5.0 branch variant.
.github/workflows/packages_components.yml Switch trigger to pull_request for component package CI on 2026.x.
.github/workflows/packages_components-5.1.yml Same trigger hardening for the 5.1 branch variant.
.github/workflows/packages_components-5.0.yml Same trigger hardening for the 5.0 branch variant.
.github/workflows/packages_bundles.yml Switch trigger to pull_request for bundle package CI on 2026.x.
.github/workflows/packages_bundles-5.1.yml Same trigger hardening for the 5.1 branch variant.
.github/workflows/packages_bundles-5.0.yml Same trigger hardening for the 5.0 branch variant.
.github/workflows/license-check.yaml Switch trigger to pull_request to avoid running fork code with secrets.
.github/workflows/license-check-5.1.yaml Same trigger hardening for the 5.1 branch variant.
.github/workflows/license-check-5.0.yaml Same trigger hardening for the 5.0 branch variant.
.github/workflows/frontend-build.yaml Switch to pull_request and add same-repo guard for the auto-commit build job.
.github/workflows/behat.yml Switch trigger to pull_request for Behat CI on 2026.x.
.github/workflows/behat-5.1.yml Same trigger hardening for the 5.1 branch variant.
.github/workflows/behat-5.0.yml Same trigger hardening for the 5.0 branch variant.
.github/workflows/behat_ui.yml Switch trigger to pull_request for UI Behat CI on 2026.x.
.github/workflows/behat_ui-5.1.yml Same trigger hardening for the 5.1 branch variant.
.github/workflows/behat_ui-5.0.yml Same trigger hardening for the 5.0 branch variant.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +14 to 19
# Only run on same-repo branches. Fork PRs get a read-only token under
# `pull_request`, so the auto-commit push would fail anyway.
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
permissions:
contents: write
uses: ./.github/workflows/shared-frontend-build.yaml
Copilot AI review requested due to automatic review settings July 24, 2026 17:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants